package starsservice.com.kc.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import common.common.Util.JWTutil;
import starsservice.com.kc.Util.ResponseJson;
import starsservice.com.kc.bean.SecretProtection;
import org.springframework.stereotype.Service;
import starsservice.com.kc.mapper.SecretProtectionMapper;
import starsservice.com.kc.service.ISecretProtectionService;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jobob
 * @since 2019-12-13
 */
@Service
public class SecretProtectionServiceImpl extends ServiceImpl<SecretProtectionMapper, SecretProtection> implements ISecretProtectionService {

    @Resource
    private SecretProtectionMapper secretProtectionMapper;

    /**
     * 添加密保接口
     * @param secretProtections
     * @param token
     * @return
     */
    @Override
    public ResponseJson addSecurity(SecretProtection secretProtections, String token) {
        String id = JWTutil.GetPayload(token,"visibleId");
        secretProtections.setAccountId(id);
        int i = secretProtectionMapper.insert(secretProtections);
        if (i>0){
            return new ResponseJson(200,"success",null);
        }
        return new ResponseJson(200,"error",null);
    }
}
